import ResultWrapper = require('../ResultWrapper')
import RequestResult = require("../RequestResult")
import RequestListResult = require("../RequestListResult")
import BaseModel = require('../BaseModel')
import Repository = require('../model/Repository')
//code1

//code1

/**
 * 仓库列表
 */
class StockApiListRepositories {
    
    get path(): string {
        return '/StockApi/listRepositories'
    }
    
    get isUpload(): boolean {
        return false
    }

    setup(app: any, path: string) {
        console.log('setup service: /' + path)
    }

    //GET
    find(params: any, callback: Function) {
        return this.doWork(params.query)
    }

    doWork(params: any): Promise<any> {

        let page = params.page
        let page_size = params.page_size || RequestListResult.PAGE_SIZE


        let callback = (
            resolve: (data: RequestListResult<Repository>) => void, 
            reject: (error: Error) => void) => {

            let data = new Repository()
            let result = ResultWrapper.wrapList([data])
            result.page = page
            result.page_size = page_size
            result.total_count = 3 * page_size + page_size/2
            result.message = '假数据'

//code2

//code2
            resolve(result)
        }
        return new Promise(callback)
    }
}

export = StockApiListRepositories